import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: '/',
    component: () => import(/* webpackChunkName: "about" */ '../layout'),
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('@/views/home/index.vue')
      },
      {
        path: 'users',
        name: 'users',
        component: () => import('@/views/users/index.vue')
      },
      {
        path: 'menus',
        name: 'menus',
        component: () => import('@/views/menus/index.vue')
      },
      {
        path: 'logs',
        name: 'logs',
        component: () => import('@/views/logs/index.vue'),
        redirect: 'loginLog',
        children: [
          {
            path: 'loginLog',
            name: 'loginLog',
            component: () => import('@/views/logs/LoginLog.vue')
          },
          {
            path: 'opraLog',
            name: 'opraLog',
            component: () => import('@/views/logs/OpraLog.vue')
          }
        ]
      },
      {
        path: 'system',
        name: 'system',
        component: () => import('@/views/system/index.vue'),
        redirect: 'userInfo',
        children: [
          {
            name: 'userInfo',
            path: 'userInfo',
            component: () => import('@/views/system/UserInfo.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/login')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
